<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="4" :xs="24">

      </el-col>
      <el-col :span="20" :xs="24">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        </el-form>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="success"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="importTwo"
            >客户账单--分区和计费重计算</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="info"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="cost"
            >费用成本计算</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>
        <!--              很长的费用成本计算-->
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="info"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="Longcost"
            >原始账单一尾程成本 AM/ECO核对（价格：2025年01月19日版）</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="info"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="LongCostBusy"
            >原始账单一尾程成本 AM/ECO核对（旺季版本）</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>


        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="surroundCost"
            >供应链端一尾程成本 AM/ECO测算（价格：2025年01月19日版）</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="surroundCostBusy"
            >供应链端一尾程成本 AM/ECO测算（旺季）</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="customerCost"
            >客户账单一尾程报价AM/ECO/AEO/AE核对(价格:2025年01月19日版)</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="customerCostStandard"
            >客户账单一尾程报价AM/AEO/AE核对(9月30日-标准)</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="customerCostVip"
            >客户账单一尾程报价AM/AEO/ECO核对(VVIP)</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="draggingCabinet"
            >客户账单一拖柜数据核对</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
        </el-row>



          <el-table-column
            label="操作"
            align="center"
            width="160"
            class-name="small-padding fixed-width"
          >
            <template slot-scope="scope" v-if="scope.row.userId !== 1">
            </template>
          </el-table-column>

      </el-col>
    </el-row>

    <!-- 添加或修改用户配置对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
  <el-upload
    ref="upload"
    :limit="1"
    accept=".xlsx, .xls"
    :headers="upload.headers"
    :action="upload.url + '?updateSupport=' + upload.updateSupport"
    :disabled="upload.isUploading"
    :http-request="uploadFile"
    :auto-upload="false"
    drag
  >
    <i class="el-icon-upload"></i>
    <div class="el-upload__text">
      将文件拖到此处，或
      <em>点击上传</em>
    </div>
    <div class="el-upload__tip" slot="tip">
    </div>
    <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
  </el-upload>
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="submitFileForm">确 定</el-button>
    <el-button @click="upload.open = false">取 消</el-button>
  </div>
</el-dialog>


<!-- 一次导入两个文件 -->
<el-dialog :title="twoToOneUpload.title" :visible.sync="twoToOneUpload.open" width="400px">
  <el-upload
    ref="twoToOneUpload"
    :limit="2"
    accept=".xlsx, .xls"
    :headers="twoToOneUpload.headers"
    :action="twoToOneUpload.url + '?updateSupport=' + twoToOneUpload.updateSupport"
    :disabled="twoToOneUpload.isUploading"
    :http-request="uploadTwoFiles"
    :on-change="handleTwoFilesChange"
    :auto-upload="false"
    drag>
    <i class="el-icon-upload"></i>
    <div class="el-upload__text">
      将文件拖到此处，或
      <em>点击上传</em>
    </div>
    <div class="el-upload__tip" slot="tip">
    </div>
    <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
  </el-upload>
  <div slot="footer" class="dialog-footer">
    <el-button @click="partitionWeightExport">模板下载</el-button>
    <el-button type="primary" @click="submitTwoFiles">确 定</el-button>
    <el-button @click="twoToOneUpload.open = false">取 消</el-button>
  </div>
</el-dialog>

    <!-- 成本计算弹窗 -->
    <el-dialog :title="twoToOneUploadCost.title" :visible.sync="twoToOneUploadCost.open" width="400px">
      <el-upload
        ref="twoToOneUploadCost"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="twoToOneUploadCost.headers"
        :action="twoToOneUploadCost.url + '?updateSupport=' + twoToOneUploadCost.updateSupport"
        :disabled="twoToOneUploadCost.isUploading"
        :http-request="uploadTwoFilesCost"
        :on-change="handleTwoFilesChangeCost"
        :auto-upload="false"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button @click="costExport">模板下载</el-button>
        <el-button type="primary" @click="submitTwoFilesCost">确 定</el-button>
        <el-button @click="twoToOneUploadCost.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 很长的成本计算弹窗 -->
    <el-dialog :title="twoToOneUploadLongCost.title" :visible.sync="twoToOneUploadLongCost.open" width="400px">
      <el-upload
        ref="twoToOneUploadLongCost"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="twoToOneUploadLongCost.headers"
        :action="twoToOneUploadLongCost.url + '?updateSupport=' + twoToOneUploadLongCost.updateSupport"
        :disabled="twoToOneUploadLongCost.isUploading"
        :http-request="uploadTwoFilesCost"
        :on-change="handleTwoFilesChangeLongCost"
        :auto-upload="false"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：根据顾师傅处理完原始账单的数据,拆分成文件名AM/ECO再导入</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="oldSubmitTwoFilesLongCost">确 定(5.26之前)</el-button>
        <el-button type="primary" @click="submitTwoFilesLongCost">确 定</el-button>
        <el-button @click="twoToOneUploadLongCost.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 很长的成本计算弹窗(旺季) -->
    <el-dialog :title="twoToOneUploadLongCostBusy.title" :visible.sync="twoToOneUploadLongCostBusy.open" width="400px">
      <el-upload
        ref="twoToOneUploadLongCostBusy"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="twoToOneUploadLongCostBusy.headers"
        :action="twoToOneUploadLongCostBusy.url + '?updateSupport=' + twoToOneUploadLongCostBusy.updateSupport"
        :disabled="twoToOneUploadLongCostBusy.isUploading"
        :http-request="uploadTwoFilesCost"
        :on-change="handleTwoFilesChangeLongCostBusy"
        :auto-upload="false"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：根据顾师傅处理完原始账单的数据,拆分成文件名AM/ECO再导入</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitTwoFilesLongCostBusy">确 定</el-button>
        <el-button @click="twoToOneUploadLongCostBusy.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 带围长的成本计算弹窗 -->
    <el-dialog :title="twoToOneUploadSurroundCost.title" :visible.sync="twoToOneUploadSurroundCost.open" width="400px">
      <el-upload
        ref="twoToOneUploadSurroundCost"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="twoToOneUploadSurroundCost.headers"
        :action="twoToOneUploadSurroundCost.url + '?updateSupport=' + twoToOneUploadSurroundCost.updateSupport"
        :disabled="twoToOneUploadSurroundCost.isUploading"
        :http-request="uploadTwoFilesCost"
        :on-change="handleTwoFilesChangeSurroundCost"
        :auto-upload="false"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：文件名注意名称 例如:AM    注意:实重为g(克)</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <div style="margin-bottom: 10px">
          <el-button @click="handleExportTemplate">模板导出</el-button>
          <el-button @click="twoToOneUploadSurroundCost.open = false">取 消</el-button>
        </div>
        <div>
          <el-button type="primary" @click="oldSubmitTwoFilesSurroundCost">确 定(05/26之前)</el-button>
          <el-button type="primary" @click="submitTwoFilesSurroundCost">确 定</el-button>

        </div>
      </div>
    </el-dialog>
    <!-- 带围长的成本计算弹窗-旺季 -->
    <el-dialog :title="twoToOneUploadSurroundCostBusy.title" :visible.sync="twoToOneUploadSurroundCostBusy.open" width="400px">
      <el-upload
        ref="twoToOneUploadSurroundCostBusy"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="twoToOneUploadSurroundCostBusy.headers"
        :action="twoToOneUploadSurroundCostBusy.url + '?updateSupport=' + twoToOneUploadSurroundCostBusy.updateSupport"
        :disabled="twoToOneUploadSurroundCostBusy.isUploading"
        :http-request="uploadTwoFilesCost"
        :on-change="handleTwoFilesChangeSurroundCostBusy"
        :auto-upload="false"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：文件名注意名称 例如:AM    注意:实重为g(克)</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <div style="margin-bottom: 10px">
          <el-button type="primary" @click="submitTwoFilesSurroundCostBusy">确 定</el-button>
          <el-button @click="twoToOneUploadSurroundCostBusy.open = false">取 消</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 客户的的成本计算弹窗 -->
    <el-dialog :title="twoToOneUploadCustomerCost.title" :visible.sync="twoToOneUploadCustomerCost.open" width="400px">
      <el-upload
        ref="twoToOneUploadCustomerCost"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="twoToOneUploadCustomerCost.headers"
        :action="twoToOneUploadCustomerCost.url + '?updateSupport=' + twoToOneUploadCustomerCost.updateSupport"
        :disabled="twoToOneUploadCustomerCost.isUploading"
        :http-request="uploadTwoFilesCost"
        :on-change="handleTwoFilesChangeCustomerCost"
        :auto-upload="false"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleExportCustomer">模板下载</el-button>
        <el-button type="primary" @click="submitTwoFilesCustomerCost">确 定</el-button>
        <el-button @click="twoToOneUploadCustomerCost.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 客户的的成本计算弹窗(标准) -->
    <el-dialog :title="twoToOneUploadCustomerCostStandard.title" :visible.sync="twoToOneUploadCustomerCostStandard.open" width="400px">
      <el-upload
        ref="twoToOneUploadCustomerCostStandard"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="twoToOneUploadCustomerCostStandard.headers"
        :action="twoToOneUploadCustomerCostStandard.url + '?updateSupport=' + twoToOneUploadCustomerCostStandard.updateSupport"
        :disabled="twoToOneUploadCustomerCostStandard.isUploading"
        :http-request="uploadTwoFilesCost"
        :on-change="handleTwoFilesChangeCustomerCostStandard"
        :auto-upload="false"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleExportCustomer">模板下载</el-button>
        <el-button type="primary" @click="submitTwoFilesCustomerCostStandard">确 定</el-button>
        <el-button @click="twoToOneUploadCustomerCostStandard.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 客户的的成本计算弹窗(vip) -->
    <el-dialog :title="twoToOneUploadCustomerCostVip.title" :visible.sync="twoToOneUploadCustomerCostVip.open" width="400px">
      <el-upload
        ref="twoToOneUploadCustomerCostVip"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="twoToOneUploadCustomerCostVip.headers"
        :action="twoToOneUploadCustomerCostVip.url + '?updateSupport=' + twoToOneUploadCustomerCostVip.updateSupport"
        :disabled="twoToOneUploadCustomerCostVip.isUploading"
        :http-request="uploadTwoFilesCost"
        :on-change="handleTwoFilesChangeCustomerCostVip"
        :auto-upload="false"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleExportCustomer">模板下载</el-button>
        <el-button type="primary" @click="submitTwoFilesCustomerCostVip">确 定</el-button>
        <el-button @click="twoToOneUploadCustomerCostVip.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 拖柜费成本计算弹窗 -->
    <el-dialog :title="twoToOneUploadDraggingCabinet.title" :visible.sync="twoToOneUploadDraggingCabinet.open" width="400px">
      <el-upload
        ref="twoToOneUploadDraggingCabinet"
        :limit="2"
        accept=".xlsx, .xls"
        :headers="twoToOneUploadDraggingCabinet.headers"
        :action="twoToOneUploadDraggingCabinet.url + '?updateSupport=' + twoToOneUploadDraggingCabinet.updateSupport"
        :disabled="twoToOneUploadDraggingCabinet.isUploading"
        :http-request="uploadTwoFilesCost"
        :on-change="handleTwoFilesChangeDraggingCabinet"
        :auto-upload="false"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：先选择拖柜账单在选择拖柜发票</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button @click="draggingCabinetExportTemplate">模板下载</el-button>
        <el-button type="primary" @click="submitTwoFilesDraggingCabinet">确 定</el-button>
        <el-button @click="twoToOneUploadDraggingCabinet.open = false">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
// import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user";
import { getToken } from "@/utils/auth";
import axios from "axios";
import { Loading } from 'element-ui';
// import Treeselect from "@riophae/vue-treeselect";
// import "@riophae/vue-treeselect/dist/vue-treeselect.css";

export default {
  name: "User",
  dicts: ['sys_normal_disable', 'sys_user_sex'],
  // components: { Treeselect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      userList: null,
      // 弹出层标题
      title: "",
      // 部门树选项
      deptOptions: undefined,
      // 是否显示弹出层
      open: false,
      // 部门名称
      deptName: undefined,
      // 默认密码
      initPassword: undefined,
      // 日期范围
      dateRange: [],
      // 岗位选项
      postOptions: [],
      // 角色选项
      roleOptions: [],
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 导入库内操作并导出
      upload: {
        open: false,
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/amac/finance/importLibraryOperations"
      },
       // 导入物流明细
       logisticsUpload: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        url: process.env.VUE_APP_BASE_API + "/amac/finance/importLogisticsDetails"
      },
          // 导入二合一
          twoToOneUpload: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        //url: process.env.VUE_APP_BASE_API + "/amac/finance/twoToOne"
        fileList: [] // 存储两个文件的列表
      },
      // 成本
      twoToOneUploadCost: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        //url: process.env.VUE_APP_BASE_API + "/amac/finance/twoToOne"
        fileList: [] // 存储两个文件的列表
      },
      // 很长的成本
      twoToOneUploadLongCost: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        //url: process.env.VUE_APP_BASE_API + "/amac/finance/twoToOne"
        fileList: [] // 存储两个文件的列表
      },
      // 很长的成本-旺季
      twoToOneUploadLongCostBusy: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        //url: process.env.VUE_APP_BASE_API + "/amac/finance/twoToOne"
        fileList: [] // 存储两个文件的列表
      },
      //供应链端-尾程成本 AM/ECO测算（价格：2025年01月19日版）
      twoToOneUploadSurroundCost: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        //url: process.env.VUE_APP_BASE_API + "/amac/finance/twoToOne"
        fileList: [] // 存储两个文件的列表
      },
      //供应链端-尾程成本 AM/ECO测算（旺季）
      twoToOneUploadSurroundCostBusy: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        //url: process.env.VUE_APP_BASE_API + "/amac/finance/twoToOne"
        fileList: [] // 存储两个文件的列表
      },
      // 客户的成本
      twoToOneUploadCustomerCost: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        //url: process.env.VUE_APP_BASE_API + "/amac/finance/twoToOne"
        fileList: [] // 存储两个文件的列表
      },
      // 客户的成本(标准)
      twoToOneUploadCustomerCostStandard: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        //url: process.env.VUE_APP_BASE_API + "/amac/finance/twoToOne"
        fileList: [] // 存储两个文件的列表
      },
      // 客户的成本(vip)
      twoToOneUploadCustomerCostVip: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        //url: process.env.VUE_APP_BASE_API + "/amac/finance/twoToOne"
        fileList: [] // 存储两个文件的列表
      },
      // 拖柜费成本
      twoToOneUploadDraggingCabinet: {
        open: false,
        title: "",
        isUploading: false,
        updateSupport: 0,
        headers: { Authorization: "Bearer " + getToken() },
        //url: process.env.VUE_APP_BASE_API + "/amac/finance/twoToOne"
        fileList: [] // 存储两个文件的列表
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        phonenumber: undefined,
        status: undefined,
        deptId: undefined
      },
      // 列信息
      columns: [
        { key: 0, label: `用户编号`, visible: true },
        { key: 1, label: `用户名称`, visible: true },
        { key: 2, label: `用户昵称`, visible: true },
        { key: 3, label: `部门`, visible: true },
        { key: 4, label: `手机号码`, visible: true },
        { key: 5, label: `状态`, visible: true },
        { key: 6, label: `创建时间`, visible: true }
      ],
      // 表单校验
      rules: {
        userName: [
          { required: true, message: "用户名称不能为空", trigger: "blur" },
          { min: 2, max: 20, message: '用户名称长度必须介于 2 和 20 之间', trigger: 'blur' }
        ],
        nickName: [
          { required: true, message: "用户昵称不能为空", trigger: "blur" }
        ],
        password: [
          { required: true, message: "用户密码不能为空", trigger: "blur" },
          { min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' },
          { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符：< > \" ' \\\ |", trigger: "blur" }
        ],
        email: [
          {
            type: "email",
            message: "请输入正确的邮箱地址",
            trigger: ["blur", "change"]
          }
        ],
        phonenumber: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur"
          }
        ]
      }
    };
  },
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val);
    }
  },
  created() {
    this.getList();
    this.getDeptTree();
    this.getConfigKey("sys.user.initPassword").then(response => {
      this.initPassword = response.msg;
    });
  },
  methods: {
    /** 导出模板按钮操作 */
    handleExportTemplate() {
      this.twoToOneUploadSurroundCost.open = false;
      this.download('amac/finance/exportTemplate', {
      }, `成本数据模板_${new Date().getTime()}.xlsx`)
    },

    /** 拖柜模板按钮操作 */
    draggingCabinetExportTemplate() {
      this.twoToOneUploadDraggingCabinet.open = false;
      this.download('amac/finance/draggingCabinetExportTemplate', {
      }, `拖柜账单模板_${new Date().getTime()}.xlsx`)
    },

    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    // 节点单击事件
    handleNodeClick(data) {
      this.queryParams.deptId = data.id;
      this.handleQuery();
    },
    // 用户状态修改
    handleStatusChange(row) {
      let text = row.status === "0" ? "启用" : "停用";
      this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗？').then(function() {
        return changeUserStatus(row.userId, row.status);
      }).then(() => {
        this.$modal.msgSuccess(text + "成功");
      }).catch(function() {
        row.status = row.status === "0" ? "1" : "0";
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: "0",
        remark: undefined,
        postIds: [],
        roleIds: []
      };
      this.resetForm("form");
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    // 更多操作触发
    handleCommand(command, row) {
      switch (command) {
        case "handleResetPwd":
          this.handleResetPwd(row);
          break;
        case "handleAuthRole":
          this.handleAuthRole(row);
          break;
        default:
          break;
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/user/export', {
        ...this.queryParams
      }, `user_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "库内操作导入";
      this.upload.open = true;
    },
     /** 导入二合一 */
     importTwo() {
      this.twoToOneUpload.title = "库内操作和物流费用明细导入";
      this.twoToOneUpload.open = true;
    },
    /** 成本计算按钮方法 */
    cost() {
      this.twoToOneUploadCost.title = "费用明细成本";
      this.twoToOneUploadCost.open = true;
    },

    /** 很长的成本计算按钮方法 */
    Longcost() {
      this.twoToOneUploadLongCost.title = "原始账单-尾程成本 AM/ECO核对（价格：2025年01月19日版）";
      this.twoToOneUploadLongCost.open = true;
    },
    /** 很长的成本计算按钮方法 */
    LongCostBusy() {
      this.twoToOneUploadLongCostBusy.title = "原始账单-尾程成本 AM/ECO核对（旺季）";
      this.twoToOneUploadLongCostBusy.open = true;
    },

    /** 带围长的成本计算按钮方法 */
    surroundCost() {
      this.twoToOneUploadSurroundCost.title = "供应链端-尾程成本 AM/ECO测算（价格：2025年01月19日版）";
      this.twoToOneUploadSurroundCost.open = true;
    },
    /** 带围长的成本计算按钮方法 旺季*/
    surroundCostBusy() {
      this.twoToOneUploadSurroundCostBusy.title = "供应链端-尾程成本 AM/ECO测算（价格：2025年01月19日版）";
      this.twoToOneUploadSurroundCostBusy.open = true;
    },
    /** 客户的的成本计算按钮方法 */
    customerCost() {
      this.twoToOneUploadCustomerCost.title = "客户的的成本计算";
      this.twoToOneUploadCustomerCost.open = true;
    },
    /** 客户的的成本计算按钮方法 标准 */
    customerCostStandard() {
      this.twoToOneUploadCustomerCostStandard.title = "客户的的成本计算(标准)";
      this.twoToOneUploadCustomerCostStandard.open = true;
    },
    /** 客户的的成本计算按钮方法 vip*/
    customerCostVip() {
      this.twoToOneUploadCustomerCostVip.title = "客户的的成本计算(Vip)";
      this.twoToOneUploadCustomerCostVip.open = true;
    },

    /** 拖柜费成本计算按钮方法 */
    draggingCabinet() {
      this.twoToOneUploadDraggingCabinet.title = "拖柜费成本计算";
      this.twoToOneUploadDraggingCabinet.open = true;
    },

    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    // // //物流费用明细提交
    // submitFileDetial() {
    //   this.$refs.logisticsUpload.submit();
    // },

        // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.logisticsUpload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.logisticsUpload.open = false;
      this.logisticsUpload.isUploading = false;
      this.$refs.logisticsUpload.clearFiles();
      this.$alert("导入成功");
    },
     // 自定义上传请求
     uploadFile({ file, onProgress, onSuccess, onError }) {
      this.upload.isUploading = true;
      const formData = new FormData();
      formData.append('file', file);
      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/importLibraryOperations',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);
        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          this.upload.isUploading = false;
          this.$refs.upload.clearFiles()
          this.upload.open = false;  // 关闭弹窗

        });
    },

    handleTwoFilesChange(file, fileList) {
    this.twoToOneUpload.fileList = fileList.slice(0, 1);
  },
    handleTwoFilesChangeCost(file, fileList) {
      this.twoToOneUploadCost.fileList = fileList.slice(0, 1);
    },
    handleTwoFilesChangeLongCost(file, fileList) {
      this.twoToOneUploadLongCost.fileList = fileList.slice(0, 1);
    },
    handleTwoFilesChangeLongCostBusy(file, fileList) {
      this.twoToOneUploadLongCostBusy.fileList = fileList.slice(0, 1);
    },
    handleTwoFilesChangeSurroundCost(file, fileList) {
      this.twoToOneUploadSurroundCost.fileList = fileList.slice(0, 1);
    },
    handleTwoFilesChangeSurroundCostBusy(file, fileList) {
      this.twoToOneUploadSurroundCostBusy.fileList = fileList.slice(0, 1);
    },
    handleTwoFilesChangeCustomerCost(file, fileList) {
      this.twoToOneUploadCustomerCost.fileList = fileList.slice(0, 1); // 限制文件列表为1个文件
    },
    handleTwoFilesChangeCustomerCostStandard(file, fileList) {
      this.twoToOneUploadCustomerCostStandard.fileList = fileList.slice(0, 1); // 限制文件列表为1个文件
    },
    handleTwoFilesChangeCustomerCostVip(file, fileList) {
      this.twoToOneUploadCustomerCostVip.fileList = fileList.slice(0, 1); // 限制文件列表为1个文件
    },
    handleTwoFilesChangeDraggingCabinet(file, fileList) {
      this.twoToOneUploadDraggingCabinet.fileList = fileList.slice(0, 2); // 限制文件列表为2个文件
    },
  submitTwoFiles() {
    if (this.twoToOneUpload.fileList.length !== 1) {
      this.$message.error('请上传1个文件');
      return;
    }
    this.uploadTwoFiles({
    file: this.twoToOneUpload.fileList,
    onProgress: this.handleFileUploadProgress,
    onSuccess: this.handleFileSuccess,
    onError: this.handleFileError
  });
  },
    /*成本*/
    submitTwoFilesCost() {
      if (this.twoToOneUploadCost.fileList.length !== 1) {
        this.$message.error('请上传1个文件');
        return;
      }
      this.uploadTwoFilesCost({
        file: this.twoToOneUploadCost.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },
    /*很长的成本老的*/
    oldSubmitTwoFilesLongCost() {
      if (this.twoToOneUploadLongCost.fileList.length !== 1) {
        this.$message.error('请上传1个文件');
        return;
      }
      this.oldUploadTwoFilesLongCost({
        file: this.twoToOneUploadLongCost.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },
    /*很长的成本新的*/
    submitTwoFilesLongCost() {
      if (this.twoToOneUploadLongCost.fileList.length !== 1) {
        this.$message.error('请上传1个文件');
        return;
      }
      this.uploadTwoFilesLongCost({
        file: this.twoToOneUploadLongCost.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },
    /*很长的成本旺季*/
    submitTwoFilesLongCostBusy() {
      if (this.twoToOneUploadLongCostBusy.fileList.length !== 1) {
        this.$message.error('请上传1个文件');
        return;
      }
      this.uploadTwoFilesLongCostBusy({
        file: this.twoToOneUploadLongCostBusy.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },
    /**
     * 带围长的的成本之前
     */
    oldSubmitTwoFilesSurroundCost() {
      if (this.twoToOneUploadSurroundCost.fileList.length !== 1) {
        this.$message.error('请上传1个文件');
        return;
      }
      this.oldUploadTwoFilesSurroundCost({
        file: this.twoToOneUploadSurroundCost.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },
    /*带围长的的成本*/
    submitTwoFilesSurroundCost() {
      if (this.twoToOneUploadSurroundCost.fileList.length !== 1) {
        this.$message.error('请上传1个文件');
        return;
      }
      this.uploadTwoFilesSurroundCost({
        file: this.twoToOneUploadSurroundCost.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },
    /*带围长的的成本 旺季*/
    submitTwoFilesSurroundCostBusy() {
      if (this.twoToOneUploadSurroundCostBusy.fileList.length !== 1) {
        this.$message.error('请上传1个文件');
        return;
      }
      this.uploadTwoFilesSurroundCostBusy({
        file: this.twoToOneUploadSurroundCostBusy.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },
    /*客户的的的成本*/
    submitTwoFilesCustomerCost() {
      if (this.twoToOneUploadCustomerCost.fileList.length !== 1) {
        this.$message.error('请上传1个文件');
        return;
      }
      this.uploadTwoFilesCustomerCost({
        file: this.twoToOneUploadCustomerCost.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },
    /*客户的的的成本标准版*/
    submitTwoFilesCustomerCostStandard() {
      if (this.twoToOneUploadCustomerCostStandard.fileList.length !== 1) {
        this.$message.error('请上传1个文件');
        return;
      }
      this.uploadTwoFilesCustomerCostStandard({
        file: this.twoToOneUploadCustomerCostStandard.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },
    /*客户的的的成本vip版*/
    submitTwoFilesCustomerCostVip() {
      if (this.twoToOneUploadCustomerCostVip.fileList.length !== 1) {
        this.$message.error('请上传1个文件');
        return;
      }
      this.uploadTwoFilesCustomerCostVip({
        file: this.twoToOneUploadCustomerCostVip.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },

    /*拖柜费成本*/
    submitTwoFilesDraggingCabinet() {
      if (this.twoToOneUploadDraggingCabinet.fileList.length !== 2) {
        this.$message.error('请上传2个文件');
        return;
      }
      this.uploadTwoFilesDraggingCabinet({
        file: this.twoToOneUploadDraggingCabinet.fileList,
        onProgress: this.handleFileUploadProgress,
        onSuccess: this.handleFileSuccess,
        onError: this.handleFileError
      });
    },

    // 二合一自定义上传请求
    uploadTwoFiles({ file, onProgress, onSuccess, onError }) {
      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUpload.isUploading = true;
      const formData = new FormData();
       // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('operationsFile', this.twoToOneUpload.fileList[0].raw); // operationsFile

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/twoToOne',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
      if (progressEvent.lengthComputable) {
        const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
        onProgress({ percent: percentCompleted });
      }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
    if (this.loadingInstance) {
      this.loadingInstance.close();
    }
          this.twoToOneUpload.isUploading = false;
          this.$refs.twoToOneUpload.clearFiles()
          this.twoToOneUpload.open = false;  // 关闭弹窗

        });
    },
    // 成本二合一自定义上传请求
    uploadTwoFilesCost({ file, onProgress, onSuccess, onError }) {
      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadCost.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('costFile', this.twoToOneUploadCost.fileList[0].raw); // 只有一个文件

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/cost',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadCost.isUploading = false;
          this.$refs.twoToOneUploadCost.clearFiles()
          this.twoToOneUploadCost.open = false;  // 关闭弹窗

        });
    },
    // 很长的二合一自定义上传请求老的
    oldUploadTwoFilesLongCost({ file, onProgress, onSuccess, onError }) {
      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadLongCost.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('costFile', this.twoToOneUploadLongCost.fileList[0].raw); // 只有一个文件

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/oldLongCost',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadLongCost.isUploading = false;
          this.$refs.twoToOneUploadLongCost.clearFiles()
          this.twoToOneUploadLongCost.open = false;  // 关闭弹窗

        });
    },
    // 很长的二合一自定义上传请求
    uploadTwoFilesLongCost({ file, onProgress, onSuccess, onError }) {
      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadLongCost.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('costFile', this.twoToOneUploadLongCost.fileList[0].raw); // 只有一个文件

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/longCost',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadLongCost.isUploading = false;
          this.$refs.twoToOneUploadLongCost.clearFiles()
          this.twoToOneUploadLongCost.open = false;  // 关闭弹窗

        });
    },
    // 很长的上传请求旺季
    uploadTwoFilesLongCostBusy({ file, onProgress, onSuccess, onError }) {
      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadLongCost.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('costFile', this.twoToOneUploadLongCostBusy.fileList[0].raw); // 只有一个文件

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/longCostBusy',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadLongCostBusy.isUploading = false;
          this.$refs.twoToOneUploadLongCostBusy.clearFiles()
          this.twoToOneUploadLongCostBusy.open = false;  // 关闭弹窗

        });
    },
    // 带围长的二合一自定义上传请求老的
    oldUploadTwoFilesSurroundCost({ file, onProgress, onSuccess, onError }) {

      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadSurroundCost.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('costFile', this.twoToOneUploadSurroundCost.fileList[0].raw); // 只有一个文件
      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/oldSurroundCost',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadSurroundCost.isUploading = false;
          this.$refs.twoToOneUploadSurroundCost.clearFiles()
          this.twoToOneUploadSurroundCost.open = false;  // 关闭弹窗

        });
    },
    // 带围长的二合一自定义上传请求
    uploadTwoFilesSurroundCost({ file, onProgress, onSuccess, onError }) {

      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadSurroundCost.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('costFile', this.twoToOneUploadSurroundCost.fileList[0].raw); // 只有一个文件

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/surroundCost',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadSurroundCost.isUploading = false;
          this.$refs.twoToOneUploadSurroundCost.clearFiles()
          this.twoToOneUploadSurroundCost.open = false;  // 关闭弹窗

        });
    },
    // 带围长的二合一自定义上传请求-旺季
    uploadTwoFilesSurroundCostBusy({ file, onProgress, onSuccess, onError }) {

      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadSurroundCostBusy.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('costFile', this.twoToOneUploadSurroundCostBusy.fileList[0].raw); // 只有一个文件

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/surroundCostBusy',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadSurroundCostBusy.isUploading = false;
          this.$refs.twoToOneUploadSurroundCostBusy.clearFiles()
          this.twoToOneUploadSurroundCostBusy.open = false;  // 关闭弹窗

        });
    },
    // 客户成本自定义上传请求
    uploadTwoFilesCustomerCost({ file, onProgress, onSuccess, onError }) {
      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadCustomerCost.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('costFile', this.twoToOneUploadCustomerCost.fileList[0].raw); // 只有一个文件

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/customerBill/customerCost',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadCustomerCost.isUploading = false;
          this.$refs.twoToOneUploadCustomerCost.clearFiles()
          this.twoToOneUploadCustomerCost.open = false;  // 关闭弹窗

        });
    },
    // 客户成本自定义上传请求标准
    uploadTwoFilesCustomerCostStandard({ file, onProgress, onSuccess, onError }) {
      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadCustomerCostStandard.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('costFile', this.twoToOneUploadCustomerCostStandard.fileList[0].raw); // 只有一个文件

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/customerBill/customerCostStandard',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadCustomerCostStandard.isUploading = false;
          this.$refs.twoToOneUploadCustomerCostStandard.clearFiles()
          this.twoToOneUploadCustomerCostStandard.open = false;  // 关闭弹窗

        });
    },
    // 客户成本自定义上传请求vip
    uploadTwoFilesCustomerCostVip({ file, onProgress, onSuccess, onError }) {
      // 显示加载框
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadCustomerCostVip.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      formData.append('costFile', this.twoToOneUploadCustomerCostVip.fileList[0].raw); // 只有一个文件

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/customerBill/customerCostVip',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadCustomerCostVip.isUploading = false;
          this.$refs.twoToOneUploadCustomerCostVip.clearFiles()
          this.twoToOneUploadCustomerCostVip.open = false;  // 关闭弹窗

        });
    },
    /**
     * 分区计费重导出模板
     */
    partitionWeightExport() {
      this.twoToOneUpload.open = false;
      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/partitionWeightExport',  // 上传的接口地址
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `分区计费重模板${new Date().getTime()}.xlsx`;
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link);
          window.URL.revokeObjectURL(downloadUrl);
        })
        .catch((error) => {
          console.error('上传失败', error);
        });
    },
    /**
     * 最初成本导出模板
     */
    costExport() {
      this.twoToOneUploadCost.open = false;
      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/costExport',  // 上传的接口地址
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `成本模板${new Date().getTime()}.xlsx`;
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link);
          window.URL.revokeObjectURL(downloadUrl);
        })
        .catch((error) => {
          console.error('上传失败', error);
        });
    },
    /**
     * 客户成本导出模板
     */
    handleExportCustomer() {
      this.twoToOneUploadCustomerCost.open = false;
      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/customerBill/customerCostTemplate',  // 上传的接口地址
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `客户成本模板${new Date().getTime()}.xlsx`;
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link);
          window.URL.revokeObjectURL(downloadUrl);
        })
        .catch((error) => {
          console.error('上传失败', error);
        });
    },
    // 拖柜费自定义上传请求
    uploadTwoFilesDraggingCabinet({ file, onProgress, onSuccess, onError }) {
      // 显示加载框e
      this.loadingInstance = Loading.service({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.twoToOneUploadDraggingCabinet.isUploading = true;
      const formData = new FormData();
      // 假设 fileList 中第一个文件是 operationsFile，第二个是 detailsFile
      console.log("111111111111111+=", this.twoToOneUploadDraggingCabinet.fileList[0].raw)
      formData.append('costFile', this.twoToOneUploadDraggingCabinet.fileList[0].raw); // 只有一个文件
      formData.append('detailsFile', this.twoToOneUploadDraggingCabinet.fileList[1].raw); // 只有一个文件
      console.log("formData=",formData)

      axios({
        method: 'post',
        url: process.env.VUE_APP_BASE_API + '/amac/finance/draggingCabinet',  // 上传的接口地址
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data',
          'Authorization': 'Bearer ' + getToken(),  // 添加授权头
        },
        onUploadProgress: (progressEvent) => {
          if (progressEvent.lengthComputable) {
            const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
            onProgress({ percent: percentCompleted });
          }
        },
        responseType: 'blob',  // 如果期望返回二进制文件，设置为 'blob'
      })
        .then((response) => {
          // 处理返回的二进制流
          const blob = new Blob([response.data], {
            type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
          });
          const downloadUrl = window.URL.createObjectURL(blob);
          const link = document.createElement('a');
          link.href = downloadUrl;
          link.download = `处理结果_${new Date().getTime()}.xlsx`;
          link.click();
          window.URL.revokeObjectURL(downloadUrl);
          onSuccess(response.data);

        })
        .catch((error) => {
          console.error('上传失败', error);
          onError(error);
        })
        .finally(() => {
          // 关闭加载框
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          this.twoToOneUploadDraggingCabinet.isUploading = false;
          this.$refs.twoToOneUploadDraggingCabinet.clearFiles()
          this.twoToOneUploadDraggingCabinet.open = false;  // 关闭弹窗

        });
    },


  }
};
</script>
